package main

import "fmt"

func main() {
	var age int
	age = 10
	fmt.Printf("%d\n", age)
	var age1 int = 10
	fmt.Println(age1)
	var age2 = 20
	fmt.Println(age2)
	age3 := 30
	fmt.Println(age3)
	var name1, name2, name3 int
	name1, name2, name3 = 1, 2, 3
	fmt.Println(name1, name2, name3)
	var name, age4, sex = "王二狗", 30, "男"
	fmt.Println(name, age4, sex)
	var (
		x int
		y int
	)
	x = 1
	y = 2
	fmt.Println(x, y)
	var z int = 20
	//z:=30
	fmt.Println(z)
	//var a string ="abc"
	fmt.Println("helloworld")
	x1 := 140
	fmt.Println(&x1)
	a1, b1 := 200, "abc"
	fmt.Println(&b1, b1)
	fmt.Println(a1)
	var aa bool
	var bb string
	var cc int
	fmt.Println(aa, bb, cc)
	const aaa int = 123
	const bbb = 456

	const LENGTH int = 10
	const WIDTH int = 5
	var area int
	const a2, b2, c2 = 1, false, "str"
	fmt.Println(a2, b2, c2)
	area = LENGTH * WIDTH
	fmt.Printf("面积为:%d\n", area)

	const (
		unknown = 0
		female  = 1
		male    = 2
	)
	fmt.Println(unknown, female, male)
	const (
		x3 uint16 = 16
		y3
		s3 = "abc"
		z3
	)
	fmt.Printf("%T,%v\n", y3, y3)
	fmt.Printf("%T,%v\n", z3, z3)
	const (
		a4 = iota
		b4 = iota
		c4 = iota
	)
	fmt.Println(c4)
	const (
		a5 = iota
		b5
		c5
	)
	fmt.Println(c5)
	const (
		a = iota //iota=0
		b        //iota=1
		c        //iota=2
		d = "ha" //"ha" iota=3
		e        //"ha" iota=4
		f = 100  //100 iota=5
		g        //100 iota=6
		h = iota //iota=7
		i        //iota=8
	)
	fmt.Println(a, b, c, d, e, f, g, h, i)
	var b3 bool = true
	fmt.Println(b3)
	var a6 string = "memda"
	fmt.Println(a6)
	var a7 string = `王二狗`
	fmt.Println(a7)
	var a8 = "a"
	fmt.Println(a8)
	var a9 = "abcdeef"
	fmt.Println(a9)
	var a10 = 'A' //这不是字符串，计算机把它当成整数来处理
	fmt.Println(a10)
	//bb2:=0
	//fmt.Scanln(&bb2)
	//fmt.Println(bb2)
	fmt.Println("pleae enter your firstname and lasetname")
	var aa1, aa2 string
	//fmt.Scan(&aa1, &aa2)
	fmt.Println("hello", aa1, "and", aa2)

	//scanf
	fmt.Println("Please enter your names")
	var bbb1, bbb2 string
	//fmt.Scanf("%s%s", &bbb1, &bbb2)
	fmt.Println(bbb1)
	fmt.Println(bbb2)

	fmt.Println("hello,", bbb1, "and", bbb2)

	var c7,c8 string
	//fmt.Scanln(&c7,&c8)
	fmt.Println("hello,",c7,"and",c8)

	//if语句
	var a89 int =10
	if a89<20 {
		fmt.Printf("a89 小于 20\n")
	}
	fmt.Printf("a89的值为：%d\n",a89)
	/*定义局部变量*/
	var d1 int =100
	var d2 int = 200
	/*判断条件*/
	if d1==100 {
		if d2==200 {
			fmt.Printf("d1的值为100,d2的值为200\n")
		}
	}
	fmt.Printf("d1的值为%d\n",d1)
	fmt.Printf("d2的值为%d\n",d2)

	if d3:=100;d3<1000 {
		fmt.Printf("d3的值为：%d\n",d3)
	}

	num1:=4
	//fmt.Scan(&num1)
	switch num1 {
	case 3:
		fmt.Println("第三季度")
		fmt.Println("第三季度")
		fmt.Println("第三季度")
	case 4:
		fmt.Println("第四季度")
		fmt.Println("第四季度")
		fmt.Println("第四季度")
		fmt.Println("第四季度")
	case 1:
		fmt.Println("第1季度")
	case 2:
		fmt.Println("第2季度")
		fmt.Println("第2季度")
	default:
		fmt.Println("我也不知道啦")
	}
	//num2:=1
	switch {
	case true:
		fmt.Println("111")
	case false:
		fmt.Println("222")
	}
	num:=1
	switch num{
	case 1,2,3,4:
		fmt.Println("1,2,3,4")
	}
	switch num2:=0;num2{
	case 0,1,2,3:
		fmt.Println("00000")
	}
	switch num3:=1;num3{
	case 1:
		fmt.Println("1")
		fallthrough
	case 2:
		fmt.Println("2")
	fallthrough
	case 3:
		fmt.Println("3")
	//fallthrough //不能穿透下面没有case的，会报错：cannot fallthrough final case in switch
	}
	fmt.Println("-------------")
	for i:=1;i<=10;i++{
		fmt.Println(i)
		if i==5{
			break
		}

	}
	for a:=10;a<20;{
		fmt.Println("a的值为：",a)
		a++
		if a>15{
			break
		}
	}
	/*
	for 表达式1;表达式2;表达式3{
		当条件满足执行此循环体
	}
	*/
	for i:=1;i<=5;i++{
		fmt.Println("helloworld")
	}
	for i:=1;i<6;i++{
		fmt.Println(i)
	}
	sum:=0
	for i:=1;i<=10;i++{
		sum=sum+i

	}
	fmt.Println(sum)

	var grade string ="B"
	var marks int =90
	switch marks {
	case 90:grade="A"
	case 80:grade="B"
	case 50,60,70:grade="C" //case后面可以有多个数值
	default:grade ="D"
	}
	switch {
	case grade=="A":
		fmt.Println("优秀\n")
	case grade=="B",grade=="C":
		fmt.Println("良好\n")
	case grade=="D":
		fmt.Println("及格\n")
	case grade=="F":
		fmt.Println("不及格\n")
	default:
		fmt.Println("差\n")
	}
	fmt.Printf("你的等级是%s\n",grade)

	switch x:=5;x{
	default:
		fmt.Println(x)
	case 5:
		x+=10
		fmt.Println(x)
		fallthrough
	case 6:
		x+=20
		fmt.Println(x)
	}
	num4:=75
	switch {
	case num4>=0 && num4<=50:
		fmt.Println("您选择的是0-50之间的数")
	case num4>=50 && num4<=100:
		fmt.Println("您选择的是50-100之间的数")
	case num4 >=101:
		fmt.Println("您选择的 100之外的数")
	}

	arr1:="abcaaaaaaa"

	count:=0
	for i:=0;i<len(arr1);i++{

		for j:=0;j<len(arr1);j++{
			if arr1[i]==arr1[j]{
				count++
			}
		}
		fmt.Printf("%q的个数为：%d\n",arr1[i],count)
		count=0


	}

	str:=[]string{"我","是"}

	for index,value:=range str {
		fmt.Println(index,value)

	}

	//fmt.Printf("%c\n",str[4])


}
